<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>系统模块信息</title>
<%@ include file="/WEB-INF/jsp/include.jsp"%>
<script type="text/javascript">
		
		var path = "${path}";
		var shStatus = new Array("停用","启用");
		var params=new Object();
		var url=path+"/system/xtMk/queryByPage";
		
		
		$(function(){
			//设置AjaxLoading
			setAjaxLoading();
			var grid=$("#tt");
			initGrid(grid);

		});
		

		//初始化表格和数据
		function initGrid(grid) {
		    var columns=[
			            { field: "id", title: "ID", hidden: true, align: "left", sortable: false, resizable: true, width: 80},		
			            { field: "code", title: "模块代码", align: "left",halign: "center", sortable: false, resizable: true, width: 100},
			            { field: "name", title: "模块名称", align: "left",halign: "center", sortable: false, resizable: true, width: 100},
			            { field: "mkxh", title: "模块序号", align: "left",halign: "center", sortable: false, resizable: true, width: 150},
			            { field: "mklx", title: "模块类型", align: "left",halign: "center", sortable: false, resizable: true, width: 100},
			            { field: "mkUrl", title: "模块 url", align: "left",halign: "center", sortable: false, resizable: true, width: 120},
			            { field: "yxbz", title: "状态", align: "center",halign: "center", sortable: false, resizable: true, width: 80,
			            	formatter: function(value,row,index){
			            		return shStatus[value];
							}
						}
			        ];

		    initPageGrid(grid, params, url,columns,"#tb");
		    getPage(grid,params,url);
		}
		
		//查询按钮
		function btnQuery(){
			params.name = $("#mkname").val();
			var grid=$("#tt");
    		getPage(grid,params,url);
		}
		 
		//增加模块
		function btnAddNode() {
			layer.open({
				  type: 2,
				  title: '系统模块 - 添加',
				  shadeClose: false,
				  shade: 0.3,
				  area: ['710px', '260px'],
				  content: '${path}/system/xtMk/toAdd' //iframe的url
				}); 
		}
		
		//修改模块
		function btnEditNodeByGrid(){
			var rows = $('#tt').datagrid('getSelections');
		    if (rows.length == 0) {
		        //$.messager.alert("友情提醒", "请选一个系统模块！", "info");
		        $.alert("pick", "info", "系统模块");
		        return;
		    }
		    layer.open({
				  type: 2,
				  title: '系统模块 - 修改',
				  shadeClose: true,
				  shade: 0.3,
				  area: ['710px', '260px'],
				  content: '${path}/system/xtMk/toUpdate' //iframe的url
			}); 

       	}
		
		//删除模块
		function btnDelNodeByGrid(){
			var rows = $('#tt').datagrid('getSelections');
		    if (rows.length == 0) {
		        //$.messager.alert("友情提醒", "请先选择系统模块信息！", "info");
		        $.alert("pick", "info", "系统模块");
		        return;
		    }	
			var rowData = rows[0];
			var param = new Object();
			param.id = rowData.id;
			$.messager.alert("问题", "请确认是否要删除？","confirm", function () {
	    			$.ajax({
		        		type:"POST",
		       			url:path+'/system/xtMk/delete',   
		        		data:param,
		       			dataType:"json",
		       			async: false,
		       			success:function callback(data){
		       				var analyMsg = data;
		       				if(analyMsg.code!="0000"){
		         				//$.messager.alert('友情提醒',analyMsg.msg,'info',function(){});
		       					$.alert("delete", "error", analyMsg.msg);
		         			}else{
		         				btnQuery();
		        			}
		       			},
		       			error: function(data ,textstatus){
		       				//$.messager.alert('友情提醒', data.responseText, 'info',function(){});
		       				$.alert("delete", "error", "模块");
		       			}
		       		});	

	        });						
			
       	}
		//启用禁用模块
		function btnYxbzNodeByGrid(){
			var rows = $('#tt').datagrid('getSelections');
		    if (rows.length == 0) {
		        //$.messager.alert("友情提醒", "请先选择模块信息！", "info");
		        $.alert("pick", "info", "模块信息");
		        return;
		    }	
			var rowData = rows[0];
			var param = new Object();
			param.id = rowData.id;
			param.yxbz = rowData.yxbz;
			var mess = "";
			if(param.yxbz == "1"){
				mess = "停用后该模块将无法使用，是否停用？";
			}else{
				mess = "是否启用";
			}
			$.messager.alert("问题", mess,"confirm", function () {

	    			$.ajax({
		        		type:"POST",
		       			url:path+'/system/xtMk/updateYxbz',
		        		data:param,
		       			dataType:"json",
		       			async: false,
		       			success:function callback(data){
		       				var analyMsg = data;
		       				if(analyMsg.code!="0000"){
		         				//$.messager.alert('友情提醒',analyMsg.msg,'info',function(){});
		       					$.alert("disabled", "error", "模块信息");
		         			}else{
		         				btnQuery();
		         			}
		       			}
		       		});	

	        });						
			
       	} 
		
		</script>
</head>

<body style="margin:0px; padding:0px;">
	<%@ include file="/WEB-INF/jsp/loading.jsp"%>
	<div class="easyui-layout" fit="true">
		<div region="center" style="padding: 5px;" border="false">
			<div class="easyui-layout" fit="true" border="false">
				<div id="divNorth" region="north" title="查询条件" border="true"
					noheader="false"
					style="padding: 5px; height: 65px; background: none repeat scroll 0 0 #EFEFEF;">
					<table>
						<tr>
							<td>模块名称：</td>
							<td><input type="text" id="mkname" name="mkname"
								style="width: 200px" /></td>
							<td><input class="anniu2" type="button"
								onclick="btnQuery();" value="查询"></td>
						</tr>
					</table>
				</div>
				<div region="center" title="" border="false" noheader="true"
					style="padding: 5px 0 0 0;">
					<table id="tt" title="" border="false"></table>
				</div>
			</div>
		</div>
	</div>

	<div id="tb" style="padding: 1px; height: auto; display: none;">
		<div>
			<a id="btn_addNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="false" onclick="btnAddNode()">新增</a> 
			<a id="btn_editNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="false" onclick="btnEditNodeByGrid()">修改</a>
			<a id="btn_delNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="false" onclick="btnDelNodeByGrid()">删除</a> 
			<a id="btn_qyNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="false" onclick="btnYxbzNodeByGrid()">启用/禁用</a>
		</div>
	</div>

</body>
</html>
